/*
 * memoDb.h
 *
 *  Created on: 19-05-2013
 *      Author: Kopik
 */

#ifndef MEMODB_H_
#define MEMODB_H_

#include <QObject>
#include <QSharedPointer>
#include <QVariantList>
#include <bb/cascades/GroupDataModel>

#include "category.hpp"
#include "question.hpp"
#include "set.hpp"

using namespace bb::cascades;

class MemoDb: public QObject {
	Q_OBJECT

	Q_PROPERTY(bb::cascades::DataModel* categoryModel READ categoryModel CONSTANT)
public:
	MemoDb();
	Q_INVOKABLE QList<QSharedPointer<Category> > getCategories();
	Q_INVOKABLE QVariantList getCategoriesModelItems();
	Q_INVOKABLE QList<QSharedPointer<Question> > getQuestions(const QString &setName);
	Q_INVOKABLE void saveSet(const Set &set, const int categoryId);
	Q_INVOKABLE void addCategory(const QString name, const QString desc);



private:
	bool m_initialized;

	bool initializeDatabase();
	void alert(const QString &message);

	bb::cascades::GroupDataModel* categoryModel();
	void updateCategoryModel();
	GroupDataModel* m_categoryModel;
};

#endif /* MEMODB_H_ */
